/**
 *
 */
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @signatureAlgorithm = 'v2';
  @endpointRule = 'regional';
  @endpointMap = {
    'cn-hangzhou' = 'mt.cn-hangzhou.aliyuncs.com',
    'ap-northeast-1' = 'mt.aliyuncs.com',
    'ap-northeast-2-pop' = 'mt.aliyuncs.com',
    'ap-south-1' = 'mt.aliyuncs.com',
    'ap-southeast-1' = 'mt.ap-southeast-1.aliyuncs.com',
    'ap-southeast-2' = 'mt.aliyuncs.com',
    'ap-southeast-3' = 'mt.aliyuncs.com',
    'ap-southeast-5' = 'mt.aliyuncs.com',
    'cn-beijing' = 'mt.aliyuncs.com',
    'cn-beijing-finance-1' = 'mt.aliyuncs.com',
    'cn-beijing-finance-pop' = 'mt.aliyuncs.com',
    'cn-beijing-gov-1' = 'mt.aliyuncs.com',
    'cn-beijing-nu16-b01' = 'mt.aliyuncs.com',
    'cn-chengdu' = 'mt.aliyuncs.com',
    'cn-edge-1' = 'mt.aliyuncs.com',
    'cn-fujian' = 'mt.aliyuncs.com',
    'cn-haidian-cm12-c01' = 'mt.aliyuncs.com',
    'cn-hangzhou-bj-b01' = 'mt.aliyuncs.com',
    'cn-hangzhou-finance' = 'mt.aliyuncs.com',
    'cn-hangzhou-internal-prod-1' = 'mt.aliyuncs.com',
    'cn-hangzhou-internal-test-1' = 'mt.aliyuncs.com',
    'cn-hangzhou-internal-test-2' = 'mt.aliyuncs.com',
    'cn-hangzhou-internal-test-3' = 'mt.aliyuncs.com',
    'cn-hangzhou-test-306' = 'mt.aliyuncs.com',
    'cn-hongkong' = 'mt.aliyuncs.com',
    'cn-hongkong-finance-pop' = 'mt.aliyuncs.com',
    'cn-huhehaote' = 'mt.aliyuncs.com',
    'cn-north-2-gov-1' = 'mt.aliyuncs.com',
    'cn-qingdao' = 'mt.aliyuncs.com',
    'cn-qingdao-nebula' = 'mt.aliyuncs.com',
    'cn-shanghai' = 'mt.aliyuncs.com',
    'cn-shanghai-et15-b01' = 'mt.aliyuncs.com',
    'cn-shanghai-et2-b01' = 'mt.aliyuncs.com',
    'cn-shanghai-finance-1' = 'mt.aliyuncs.com',
    'cn-shanghai-inner' = 'mt.aliyuncs.com',
    'cn-shanghai-internal-test-1' = 'mt.aliyuncs.com',
    'cn-shenzhen' = 'mt.aliyuncs.com',
    'cn-shenzhen-finance-1' = 'mt.aliyuncs.com',
    'cn-shenzhen-inner' = 'mt.aliyuncs.com',
    'cn-shenzhen-st4-d01' = 'mt.aliyuncs.com',
    'cn-shenzhen-su18-b01' = 'mt.aliyuncs.com',
    'cn-wuhan' = 'mt.aliyuncs.com',
    'cn-yushanfang' = 'mt.aliyuncs.com',
    'cn-zhangbei-na61-b01' = 'mt.aliyuncs.com',
    'cn-zhangjiakou' = 'mt.aliyuncs.com',
    'cn-zhangjiakou-na62-a01' = 'mt.aliyuncs.com',
    'cn-zhengzhou-nebula-1' = 'mt.aliyuncs.com',
    'eu-central-1' = 'mt.aliyuncs.com',
    'eu-west-1' = 'mt.aliyuncs.com',
    'eu-west-1-oxs' = 'mt.aliyuncs.com',
    'me-east-1' = 'mt.aliyuncs.com',
    'rus-west-1-pop' = 'mt.aliyuncs.com',
    'us-east-1' = 'mt.aliyuncs.com',
    'us-west-1' = 'mt.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('alimt', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateAsyncTranslateRequest {
  apiType?: string(name='ApiType', description='This parameter is required.', example='translate_standard'),
  formatType?: string(name='FormatType', description='This parameter is required.', example='text'),
  scene?: string(name='Scene', description='This parameter is required.', example='general'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='en'),
  sourceText?: string(name='SourceText', description='This parameter is required.', example='Opinion: We have finally gotten some relief at the pump. But it may not last long'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='zh'),
}

model CreateAsyncTranslateResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    jobId?: string(name='JobId', description='This parameter is required.', example='98bbb007-71bb-448b-bab0-2695ce8f8599'),
    status?: string(name='Status', description='This parameter is required.', example='ready'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='DC2DCCC9-C3DF-4F59-8D8E-78185729F16D'),
}

model CreateAsyncTranslateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateAsyncTranslateResponseBody(name='body'),
}

/**
 * @summary 大文本异步翻译，支持5000-50000字翻译
 *
 * @param request CreateAsyncTranslateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateAsyncTranslateResponse
 */
async function createAsyncTranslateWithOptions(request: CreateAsyncTranslateRequest, runtime: $RuntimeOptions): CreateAsyncTranslateResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.apiType)) {
    body['ApiType'] = request.apiType;
  }
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateAsyncTranslate',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 大文本异步翻译，支持5000-50000字翻译
 *
 * @param request CreateAsyncTranslateRequest
 * @return CreateAsyncTranslateResponse
 */
async function createAsyncTranslate(request: CreateAsyncTranslateRequest): CreateAsyncTranslateResponse {
  var runtime = new $RuntimeOptions{};
  return createAsyncTranslateWithOptions(request, runtime);
}

model CreateDocTranslateTaskRequest {
  callbackUrl?: string(name='CallbackUrl', example='http://callbackUrl'),
  clientToken?: string(name='ClientToken', example='token'),
  fileUrl?: string(name='FileUrl', description='This parameter is required.', example='http://fileUrl'),
  scene?: string(name='Scene', example='general'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='en'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='zh'),
}

model CreateDocTranslateTaskAdvanceRequest {
  callbackUrl?: string(name='CallbackUrl', example='http://callbackUrl'),
  clientToken?: string(name='ClientToken', example='token'),
  fileUrlObject?: readable(name='FileUrl', description='This parameter is required.', example='http://fileUrl'),
  scene?: string(name='Scene', example='general'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='en'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='zh'),
}

model CreateDocTranslateTaskResponseBody = {
  requestId?: string(name='RequestId', example='D3920BC3-A395-4CAD-9E84-7C39EB07507B'),
  status?: string(name='Status', example='ready'),
  taskId?: string(name='TaskId', example='0586df512c8b4bb382d7d9a6a01b5854'),
}

model CreateDocTranslateTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateDocTranslateTaskResponseBody(name='body'),
}

/**
 * @param request CreateDocTranslateTaskRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateDocTranslateTaskResponse
 */
async function createDocTranslateTaskWithOptions(request: CreateDocTranslateTaskRequest, runtime: $RuntimeOptions): CreateDocTranslateTaskResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!$isNull(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!$isNull(request.fileUrl)) {
    body['FileUrl'] = request.fileUrl;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateDocTranslateTask',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request CreateDocTranslateTaskRequest
 * @return CreateDocTranslateTaskResponse
 */
async function createDocTranslateTask(request: CreateDocTranslateTaskRequest): CreateDocTranslateTaskResponse {
  var runtime = new $RuntimeOptions{};
  return createDocTranslateTaskWithOptions(request, runtime);
}

async function createDocTranslateTaskAdvance(request: CreateDocTranslateTaskAdvanceRequest, runtime: $RuntimeOptions): CreateDocTranslateTaskResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if($isNull(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if($isNull(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApiUtil.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'alimt',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var createDocTranslateTaskReq = new CreateDocTranslateTaskRequest{};
  OpenApiUtil.convert(request, createDocTranslateTaskReq);

  if(!$isNull(request.fileUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.fileUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    createDocTranslateTaskReq.fileUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var createDocTranslateTaskResp = createDocTranslateTaskWithOptions(createDocTranslateTaskReq, runtime);
  return createDocTranslateTaskResp;
}

model CreateImageTranslateTaskRequest {
  clientToken?: string(name='ClientToken', example='1'),
  extra?: string(name='Extra', example='{"have_ocr":"false","without_text":"false","have_psd":"true","ignore_entity":"false"}'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
  urlList?: string(name='UrlList', description='This parameter is required.', example='http://xxx,http://yyy'),
}

model CreateImageTranslateTaskResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    taskId?: string(name='TaskId', example='A41F6E25-8520-4AF0-90EF-111111'),
  }(name='Data'),
  message?: string(name='Message', example='ok'),
  requestId?: string(name='RequestId', example='A41F6E25-8520-4AF0-90EF-AF7E32840108'),
}

model CreateImageTranslateTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateImageTranslateTaskResponseBody(name='body'),
}

/**
 * @param request CreateImageTranslateTaskRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateImageTranslateTaskResponse
 */
async function createImageTranslateTaskWithOptions(request: CreateImageTranslateTaskRequest, runtime: $RuntimeOptions): CreateImageTranslateTaskResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!$isNull(request.extra)) {
    body['Extra'] = request.extra;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  if (!$isNull(request.urlList)) {
    body['UrlList'] = request.urlList;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateImageTranslateTask',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request CreateImageTranslateTaskRequest
 * @return CreateImageTranslateTaskResponse
 */
async function createImageTranslateTask(request: CreateImageTranslateTaskRequest): CreateImageTranslateTaskResponse {
  var runtime = new $RuntimeOptions{};
  return createImageTranslateTaskWithOptions(request, runtime);
}

model GetAsyncTranslateRequest {
  jobId?: string(name='JobId', description='This parameter is required.', example='77056ab7-7be1-4c2a-91a1-f20f63894048'),
}

model GetAsyncTranslateResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    detectedLanguage?: string(name='DetectedLanguage', example='zh'),
    status?: string(name='Status', example='ready'),
    translatedText?: string(name='TranslatedText', example='hello'),
    wordCount?: string(name='WordCount', example='2'),
  }(name='Data'),
  message?: string(name='Message', example='ok'),
  requestId?: string(name='RequestId', example='DC2DCCC9-C3DF-4F59-8D8E-78185729F16D'),
}

model GetAsyncTranslateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetAsyncTranslateResponseBody(name='body'),
}

/**
 * @summary 大文本异步翻译，支持5000-50000字翻译
 *
 * @param request GetAsyncTranslateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetAsyncTranslateResponse
 */
async function getAsyncTranslateWithOptions(request: GetAsyncTranslateRequest, runtime: $RuntimeOptions): GetAsyncTranslateResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetAsyncTranslate',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 大文本异步翻译，支持5000-50000字翻译
 *
 * @param request GetAsyncTranslateRequest
 * @return GetAsyncTranslateResponse
 */
async function getAsyncTranslate(request: GetAsyncTranslateRequest): GetAsyncTranslateResponse {
  var runtime = new $RuntimeOptions{};
  return getAsyncTranslateWithOptions(request, runtime);
}

model GetBatchTranslateRequest {
  apiType?: string(name='ApiType', description='This parameter is required.', example='translate_standard'),
  formatType?: string(name='FormatType', description='This parameter is required.', example='text'),
  scene?: string(name='Scene', description='This parameter is required.', example='general'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='en'),
  sourceText?: string(name='SourceText', description='This parameter is required.', example='{"11":"hello boy","12":"go home","13":"we can"}'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='zh'),
}

model GetBatchTranslateResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='86D18195-D89C-4C8C-9DC4-5FCE789CE6D5'),
  translatedList?: [  map[string]any ](name='TranslatedList'),
}

model GetBatchTranslateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetBatchTranslateResponseBody(name='body'),
}

/**
 * @param request GetBatchTranslateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetBatchTranslateResponse
 */
async function getBatchTranslateWithOptions(request: GetBatchTranslateRequest, runtime: $RuntimeOptions): GetBatchTranslateResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.apiType)) {
    body['ApiType'] = request.apiType;
  }
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetBatchTranslate',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetBatchTranslateRequest
 * @return GetBatchTranslateResponse
 */
async function getBatchTranslate(request: GetBatchTranslateRequest): GetBatchTranslateResponse {
  var runtime = new $RuntimeOptions{};
  return getBatchTranslateWithOptions(request, runtime);
}

model GetBatchTranslateByVPCRequest {
  apiType?: string(name='ApiType', description='This parameter is required.', example='translate_standard'),
  formatType?: string(name='FormatType', description='This parameter is required.', example='text'),
  scene?: string(name='Scene', description='This parameter is required.', example='general'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  sourceText?: string(name='SourceText', description='This parameter is required.'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model GetBatchTranslateByVPCResponseBody = {
  code?: int32(name='Code', example='200'),
  message?: string(name='Message', example='Param checker failed! param:[sourceText]. reason: stringChecker not pass. Param length not less [0] and not greater[10000]'),
  requestId?: string(name='RequestId', description='Id of the request', example='DC2DCCC9-C3DF-4F59-8D8E-78185729F16D'),
  translatedList?: [  map[string]any ](name='TranslatedList'),
}

model GetBatchTranslateByVPCResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetBatchTranslateByVPCResponseBody(name='body'),
}

/**
 * @summary GetBatchTranslateByVPC
 *
 * @param request GetBatchTranslateByVPCRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetBatchTranslateByVPCResponse
 */
async function getBatchTranslateByVPCWithOptions(request: GetBatchTranslateByVPCRequest, runtime: $RuntimeOptions): GetBatchTranslateByVPCResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.apiType)) {
    body['ApiType'] = request.apiType;
  }
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetBatchTranslateByVPC',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary GetBatchTranslateByVPC
 *
 * @param request GetBatchTranslateByVPCRequest
 * @return GetBatchTranslateByVPCResponse
 */
async function getBatchTranslateByVPC(request: GetBatchTranslateByVPCRequest): GetBatchTranslateByVPCResponse {
  var runtime = new $RuntimeOptions{};
  return getBatchTranslateByVPCWithOptions(request, runtime);
}

model GetDetectLanguageRequest {
  sourceText?: string(name='SourceText', description='This parameter is required.'),
}

model GetDetectLanguageResponseBody = {
  detectedLanguage?: string(name='DetectedLanguage', example='zh'),
  languageProbabilities?: string(name='LanguageProbabilities'),
  requestId?: string(name='RequestId', example='0C5EC1EC-1A06-4D60-97E6-4D41350945E4'),
}

model GetDetectLanguageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetDetectLanguageResponseBody(name='body'),
}

/**
 * @summary 语种识别
 *
 * @param request GetDetectLanguageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetDetectLanguageResponse
 */
async function getDetectLanguageWithOptions(request: GetDetectLanguageRequest, runtime: $RuntimeOptions): GetDetectLanguageResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetDetectLanguage',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 语种识别
 *
 * @param request GetDetectLanguageRequest
 * @return GetDetectLanguageResponse
 */
async function getDetectLanguage(request: GetDetectLanguageRequest): GetDetectLanguageResponse {
  var runtime = new $RuntimeOptions{};
  return getDetectLanguageWithOptions(request, runtime);
}

model GetDetectLanguageVpcRequest {
  sourceText?: string(name='SourceText'),
}

model GetDetectLanguageVpcResponseBody = {
  detectedLanguage?: string(name='DetectedLanguage'),
  languageProbabilities?: string(name='LanguageProbabilities'),
  requestId?: string(name='RequestId'),
}

model GetDetectLanguageVpcResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetDetectLanguageVpcResponseBody(name='body'),
}

/**
 * @summary 语种识别
 *
 * @param request GetDetectLanguageVpcRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetDetectLanguageVpcResponse
 */
async function getDetectLanguageVpcWithOptions(request: GetDetectLanguageVpcRequest, runtime: $RuntimeOptions): GetDetectLanguageVpcResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetDetectLanguageVpc',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 语种识别
 *
 * @param request GetDetectLanguageVpcRequest
 * @return GetDetectLanguageVpcResponse
 */
async function getDetectLanguageVpc(request: GetDetectLanguageVpcRequest): GetDetectLanguageVpcResponse {
  var runtime = new $RuntimeOptions{};
  return getDetectLanguageVpcWithOptions(request, runtime);
}

model GetDocTranslateTaskRequest {
  taskId?: string(name='TaskId', description='This parameter is required.', example='0586df512c8b4bb382d7d9a6a01b5854'),
}

model GetDocTranslateTaskResponseBody = {
  pageCount?: int32(name='PageCount', example='20'),
  requestId?: string(name='RequestId', example='12952E92-FDF3-4D3C-88E3-242D72BA7150'),
  status?: string(name='Status', example='translated'),
  taskId?: string(name='TaskId', example='0586df512c8b4bb382d7d9a6a01b5854'),
  translateErrorCode?: string(name='TranslateErrorCode', example='Error'),
  translateErrorMessage?: string(name='TranslateErrorMessage', example='Fail to get the page number of document.'),
  translateFileUrl?: string(name='TranslateFileUrl', example='http://translateFileUrl'),
}

model GetDocTranslateTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetDocTranslateTaskResponseBody(name='body'),
}

/**
 * @summary 获取文档翻译任务
 *
 * @param request GetDocTranslateTaskRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetDocTranslateTaskResponse
 */
async function getDocTranslateTaskWithOptions(request: GetDocTranslateTaskRequest, runtime: $RuntimeOptions): GetDocTranslateTaskResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetDocTranslateTask',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取文档翻译任务
 *
 * @param request GetDocTranslateTaskRequest
 * @return GetDocTranslateTaskResponse
 */
async function getDocTranslateTask(request: GetDocTranslateTaskRequest): GetDocTranslateTaskResponse {
  var runtime = new $RuntimeOptions{};
  return getDocTranslateTaskWithOptions(request, runtime);
}

model GetImageDiagnoseRequest {
  extra?: string(name='Extra', example='{   "product_id": "1",   "platform": "ae" }'),
  url?: string(name='Url', description='This parameter is required.', example='http://xxxxx.oss-cn-shenzhen.aliyuncs.com/jd/41209/xxxxx.jpg'),
}

model GetImageDiagnoseResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    language?: string(name='Language', example='zh'),
  }(name='Data'),
  message?: string(name='Message', example='ok'),
  requestId?: string(name='RequestId', example='DC2DCCC9-C3DF-4F59-8D8E-78185729F16D'),
}

model GetImageDiagnoseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetImageDiagnoseResponseBody(name='body'),
}

/**
 * @param request GetImageDiagnoseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetImageDiagnoseResponse
 */
async function getImageDiagnoseWithOptions(request: GetImageDiagnoseRequest, runtime: $RuntimeOptions): GetImageDiagnoseResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.extra)) {
    body['Extra'] = request.extra;
  }
  if (!$isNull(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetImageDiagnose',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetImageDiagnoseRequest
 * @return GetImageDiagnoseResponse
 */
async function getImageDiagnose(request: GetImageDiagnoseRequest): GetImageDiagnoseResponse {
  var runtime = new $RuntimeOptions{};
  return getImageDiagnoseWithOptions(request, runtime);
}

model GetImageTranslateRequest {
  extra?: string(name='Extra', example='{"have_ocr": "false", "without_text":"true", "have_psd": "false", "ignore_entity": "false"}'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
  url?: string(name='Url', description='This parameter is required.', example='http://xxxxxxx.oss-cn-shenzhen.aliyuncs.com/xxxxxx.jpg'),
}

model GetImageTranslateResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    orc?: string(name='Orc'),
    pictureEditor?: string(name='PictureEditor'),
    url?: string(name='Url', example='https://ae01.alicdn.com/kf/xxxxx.jpeg'),
  }(name='Data'),
  message?: string(name='Message', example='ok'),
  requestId?: string(name='RequestId', example='A41F6E25-8520-4AF0-90EF-AF7E32840108'),
}

model GetImageTranslateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetImageTranslateResponseBody(name='body'),
}

/**
 * @param request GetImageTranslateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetImageTranslateResponse
 */
async function getImageTranslateWithOptions(request: GetImageTranslateRequest, runtime: $RuntimeOptions): GetImageTranslateResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.extra)) {
    body['Extra'] = request.extra;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  if (!$isNull(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetImageTranslate',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetImageTranslateRequest
 * @return GetImageTranslateResponse
 */
async function getImageTranslate(request: GetImageTranslateRequest): GetImageTranslateResponse {
  var runtime = new $RuntimeOptions{};
  return getImageTranslateWithOptions(request, runtime);
}

model GetImageTranslateTaskRequest {
  taskId?: string(name='TaskId', description='This parameter is required.', example='xxxxxx'),
}

model GetImageTranslateTaskResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    imageData?: string(name='ImageData', example='[{xxxxxx}]'),
  }(name='Data'),
  message?: string(name='Message', example='ok'),
  requestId?: string(name='RequestId', example='xxxxxxx'),
}

model GetImageTranslateTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetImageTranslateTaskResponseBody(name='body'),
}

/**
 * @param request GetImageTranslateTaskRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetImageTranslateTaskResponse
 */
async function getImageTranslateTaskWithOptions(request: GetImageTranslateTaskRequest, runtime: $RuntimeOptions): GetImageTranslateTaskResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetImageTranslateTask',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetImageTranslateTaskRequest
 * @return GetImageTranslateTaskResponse
 */
async function getImageTranslateTask(request: GetImageTranslateTaskRequest): GetImageTranslateTaskResponse {
  var runtime = new $RuntimeOptions{};
  return getImageTranslateTaskWithOptions(request, runtime);
}

model GetTitleDiagnoseRequest {
  categoryId?: string(name='CategoryId', description='This parameter is required.', example='123'),
  extra?: string(name='Extra', example='{   "product_id": "1",   "platform": "ae" }'),
  language?: string(name='Language', description='This parameter is required.', example='zh'),
  platform?: string(name='Platform', description='This parameter is required.', example='ae'),
  title?: string(name='Title', description='This parameter is required.', example='Amroe Japan Comic Theme Uzumaki Naruto Namikaze Minato 3D Visual Cartoon 7 Color USB Touch'),
}

model GetTitleDiagnoseResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    allUppercaseWords?: string(name='AllUppercaseWords', example='Boy'),
    containCoreClasses?: string(name='ContainCoreClasses', example='true'),
    disableWords?: string(name='DisableWords', example='baba'),
    duplicateWords?: string(name='DuplicateWords', example='hi'),
    languageQualityScore?: string(name='LanguageQualityScore', example='2'),
    noFirstUppercaseList?: string(name='NoFirstUppercaseList', example='no'),
    overLengthLimit?: string(name='OverLengthLimit', example='100'),
    totalScore?: string(name='TotalScore', example='3'),
    wordCount?: string(name='WordCount', example='10'),
    wordSpelledCorrectError?: string(name='WordSpelledCorrectError', example='ahk'),
  }(name='Data'),
  message?: string(name='Message', example='ok'),
  requestId?: string(name='RequestId', example='DC2DCCC9-C3DF-4F59-8D8E-78185729F16D'),
}

model GetTitleDiagnoseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTitleDiagnoseResponseBody(name='body'),
}

/**
 * @summary GetTitleDiagnose
 *
 * @param request GetTitleDiagnoseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTitleDiagnoseResponse
 */
async function getTitleDiagnoseWithOptions(request: GetTitleDiagnoseRequest, runtime: $RuntimeOptions): GetTitleDiagnoseResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.categoryId)) {
    body['CategoryId'] = request.categoryId;
  }
  if (!$isNull(request.extra)) {
    body['Extra'] = request.extra;
  }
  if (!$isNull(request.language)) {
    body['Language'] = request.language;
  }
  if (!$isNull(request.platform)) {
    body['Platform'] = request.platform;
  }
  if (!$isNull(request.title)) {
    body['Title'] = request.title;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetTitleDiagnose',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary GetTitleDiagnose
 *
 * @param request GetTitleDiagnoseRequest
 * @return GetTitleDiagnoseResponse
 */
async function getTitleDiagnose(request: GetTitleDiagnoseRequest): GetTitleDiagnoseResponse {
  var runtime = new $RuntimeOptions{};
  return getTitleDiagnoseWithOptions(request, runtime);
}

model GetTitleGenerateRequest {
  attributes?: string(name='Attributes', example='{2:"None",10:"Plastic"}'),
  categoryId?: string(name='CategoryId', description='This parameter is required.', example='127896018'),
  extra?: string(name='Extra', example='{   "product_id": "1",   "platform": "ae" }'),
  hotWords?: string(name='HotWords', example='None,Plastic'),
  language?: string(name='Language', description='This parameter is required.', example='en'),
  platform?: string(name='Platform', description='This parameter is required.', example='ae'),
  title?: string(name='Title', description='This parameter is required.', example='10pcs 80ml Kitchen Disposable'),
}

model GetTitleGenerateResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    titles?: string(name='Titles', example='10pcs 80ml Kitchen Disposable Plastic Sauce Cup Pot Chutney Container'),
  }(name='Data'),
  message?: string(name='Message', example='ok'),
  requestId?: string(name='RequestId', example='DC2DCCC9-C3DF-4F59-8D8E-78185729F16D'),
}

model GetTitleGenerateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTitleGenerateResponseBody(name='body'),
}

/**
 * @summary GetTitleGenerate
 *
 * @param request GetTitleGenerateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTitleGenerateResponse
 */
async function getTitleGenerateWithOptions(request: GetTitleGenerateRequest, runtime: $RuntimeOptions): GetTitleGenerateResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.attributes)) {
    body['Attributes'] = request.attributes;
  }
  if (!$isNull(request.categoryId)) {
    body['CategoryId'] = request.categoryId;
  }
  if (!$isNull(request.extra)) {
    body['Extra'] = request.extra;
  }
  if (!$isNull(request.hotWords)) {
    body['HotWords'] = request.hotWords;
  }
  if (!$isNull(request.language)) {
    body['Language'] = request.language;
  }
  if (!$isNull(request.platform)) {
    body['Platform'] = request.platform;
  }
  if (!$isNull(request.title)) {
    body['Title'] = request.title;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetTitleGenerate',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary GetTitleGenerate
 *
 * @param request GetTitleGenerateRequest
 * @return GetTitleGenerateResponse
 */
async function getTitleGenerate(request: GetTitleGenerateRequest): GetTitleGenerateResponse {
  var runtime = new $RuntimeOptions{};
  return getTitleGenerateWithOptions(request, runtime);
}

model GetTitleIntelligenceRequest {
  catLevelThreeId?: long(name='CatLevelThreeId', description='This parameter is required.', example='111'),
  catLevelTwoId?: long(name='CatLevelTwoId', description='This parameter is required.', example='222'),
  extra?: string(name='Extra', example='{"product_id":"1212"}'),
  keywords?: string(name='Keywords', example='hello,apple'),
  platform?: string(name='Platform', description='This parameter is required.', example='ae'),
}

model GetTitleIntelligenceResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    titles?: string(name='Titles', example='Custom Hello Kitty PVC Cartoon Apple for Home Garden Complete Apple Bath Shower'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='D70487B4-8891-4D24-BB64-8788E53671FB'),
}

model GetTitleIntelligenceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTitleIntelligenceResponseBody(name='body'),
}

/**
 * @summary GetTitleIntelligence
 *
 * @param request GetTitleIntelligenceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTitleIntelligenceResponse
 */
async function getTitleIntelligenceWithOptions(request: GetTitleIntelligenceRequest, runtime: $RuntimeOptions): GetTitleIntelligenceResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.catLevelThreeId)) {
    body['CatLevelThreeId'] = request.catLevelThreeId;
  }
  if (!$isNull(request.catLevelTwoId)) {
    body['CatLevelTwoId'] = request.catLevelTwoId;
  }
  if (!$isNull(request.extra)) {
    body['Extra'] = request.extra;
  }
  if (!$isNull(request.keywords)) {
    body['Keywords'] = request.keywords;
  }
  if (!$isNull(request.platform)) {
    body['Platform'] = request.platform;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetTitleIntelligence',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary GetTitleIntelligence
 *
 * @param request GetTitleIntelligenceRequest
 * @return GetTitleIntelligenceResponse
 */
async function getTitleIntelligence(request: GetTitleIntelligenceRequest): GetTitleIntelligenceResponse {
  var runtime = new $RuntimeOptions{};
  return getTitleIntelligenceWithOptions(request, runtime);
}

model GetTranslateImageBatchResultRequest {
  taskId?: string(name='TaskId', description='This parameter is required.', example='EEA28E6D-4828-5031-BD8C-8FF1B3216842'),
}

model GetTranslateImageBatchResultResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    result?: [ 
      {
        code?: int32(name='Code', example='200'),
        finalImageUrl?: string(name='FinalImageUrl', example='https://example.com/example.jpg'),
        inPaintingUrl?: string(name='InPaintingUrl', example='https://example.com/example.jpg'),
        message?: string(name='Message', example='OK'),
        sourceImageUrl?: string(name='SourceImageUrl', example='https://example.com/example.jpg'),
        success?: boolean(name='Success', example='true'),
        templateJson?: string(name='TemplateJson', example='{"TemplateJson": "Editor Template Json String	"}'),
      }
    ](name='Result'),
    status?: string(name='Status', example='finished'),
  }(name='Data'),
  message?: string(name='Message', example='OK'),
  requestId?: string(name='RequestId', example='DACD263C-C068-5116-83EC-117245AA35CF'),
}

model GetTranslateImageBatchResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTranslateImageBatchResultResponseBody(name='body'),
}

/**
 * @summary 获取图片批量翻译结果
 *
 * @param request GetTranslateImageBatchResultRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTranslateImageBatchResultResponse
 */
async function getTranslateImageBatchResultWithOptions(request: GetTranslateImageBatchResultRequest, runtime: $RuntimeOptions): GetTranslateImageBatchResultResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetTranslateImageBatchResult',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取图片批量翻译结果
 *
 * @param request GetTranslateImageBatchResultRequest
 * @return GetTranslateImageBatchResultResponse
 */
async function getTranslateImageBatchResult(request: GetTranslateImageBatchResultRequest): GetTranslateImageBatchResultResponse {
  var runtime = new $RuntimeOptions{};
  return getTranslateImageBatchResultWithOptions(request, runtime);
}

model GetTranslateReportRequest {
  apiName?: string(name='ApiName', description='This parameter is required.'),
  beginTime?: string(name='BeginTime', description='This parameter is required.', example='2021-03-01 00:00:00'),
  endTime?: string(name='EndTime', description='This parameter is required.', example='2021-03-01 23:59:59'),
  group?: string(name='Group', description='This parameter is required.'),
}

model GetTranslateReportResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: string(name='Data', example='{"result":[{"time":"2021-10-21 00:00:00","total":100}]}'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='86D18195-D89C-4C8C-9DC4-5FCE789CE6D5'),
}

model GetTranslateReportResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTranslateReportResponseBody(name='body'),
}

/**
 * @summary GetTranslateReport
 *
 * @param request GetTranslateReportRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTranslateReportResponse
 */
async function getTranslateReportWithOptions(request: GetTranslateReportRequest, runtime: $RuntimeOptions): GetTranslateReportResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.apiName)) {
    query['ApiName'] = request.apiName;
  }
  if (!$isNull(request.beginTime)) {
    query['BeginTime'] = request.beginTime;
  }
  if (!$isNull(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!$isNull(request.group)) {
    query['Group'] = request.group;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetTranslateReport',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary GetTranslateReport
 *
 * @param request GetTranslateReportRequest
 * @return GetTranslateReportResponse
 */
async function getTranslateReport(request: GetTranslateReportRequest): GetTranslateReportResponse {
  var runtime = new $RuntimeOptions{};
  return getTranslateReportWithOptions(request, runtime);
}

model OpenAlimtServiceRequest {
  ownerId?: long(name='OwnerId'),
  type?: string(name='Type', example='id'),
}

model OpenAlimtServiceResponseBody = {
  orderId?: string(name='OrderId', example='123456'),
  requestId?: string(name='RequestId', example='xxxx-xxxxx'),
}

model OpenAlimtServiceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: OpenAlimtServiceResponseBody(name='body'),
}

/**
 * @summary 开通服务
 *
 * @param request OpenAlimtServiceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return OpenAlimtServiceResponse
 */
async function openAlimtServiceWithOptions(request: OpenAlimtServiceRequest, runtime: $RuntimeOptions): OpenAlimtServiceResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!$isNull(request.type)) {
    query['Type'] = request.type;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'OpenAlimtService',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 开通服务
 *
 * @param request OpenAlimtServiceRequest
 * @return OpenAlimtServiceResponse
 */
async function openAlimtService(request: OpenAlimtServiceRequest): OpenAlimtServiceResponse {
  var runtime = new $RuntimeOptions{};
  return openAlimtServiceWithOptions(request, runtime);
}

model TranslateRequest {
  context?: string(name='Context', example='{\\\\"appName\\\\":\\\\"alynx\\\\"}'),
  formatType?: string(name='FormatType', description='This parameter is required.', example='text'),
  scene?: string(name='Scene', description='This parameter is required.', example='title'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  sourceText?: string(name='SourceText', description='This parameter is required.'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model TranslateResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    detectedLanguage?: string(name='DetectedLanguage'),
    translated?: string(name='Translated', example='Hello'),
    wordCount?: string(name='WordCount', example='10'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='86D18195-D89C-4C8C-9DC4-5FCE789CE6D5'),
}

model TranslateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateResponseBody(name='body'),
}

/**
 * @summary 专业文本翻译
 *
 * @param request TranslateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateResponse
 */
async function translateWithOptions(request: TranslateRequest, runtime: $RuntimeOptions): TranslateResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.context)) {
    query['Context'] = request.context;
  }
  var body : map[string]any = {};
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'Translate',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 专业文本翻译
 *
 * @param request TranslateRequest
 * @return TranslateResponse
 */
async function translate(request: TranslateRequest): TranslateResponse {
  var runtime = new $RuntimeOptions{};
  return translateWithOptions(request, runtime);
}

model TranslateCertificateRequest {
  certificateType?: string(name='CertificateType', description='This parameter is required.', example='driving_license'),
  imageUrl?: string(name='ImageUrl', description='This parameter is required.', example='http://imageurl'),
  resultType?: string(name='ResultType', example='text'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model TranslateCertificateAdvanceRequest {
  certificateType?: string(name='CertificateType', description='This parameter is required.', example='driving_license'),
  imageUrlObject?: readable(name='ImageUrl', description='This parameter is required.', example='http://imageurl'),
  resultType?: string(name='ResultType', example='text'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model TranslateCertificateResponseBody = {
  data?: {
    translatedValues?: [ 
      {
        key?: string(name='Key'),
        keyTranslation?: string(name='KeyTranslation', example='name'),
        value?: string(name='Value'),
        valueTranslation?: string(name='ValueTranslation', example='Solemn'),
      }
    ](name='TranslatedValues'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='6640DE48-201C-4110-AE87-FB8FA34412B9'),
}

model TranslateCertificateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateCertificateResponseBody(name='body'),
}

/**
 * @summary TranslateCertificate
 *
 * @param request TranslateCertificateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateCertificateResponse
 */
async function translateCertificateWithOptions(request: TranslateCertificateRequest, runtime: $RuntimeOptions): TranslateCertificateResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.certificateType)) {
    body['CertificateType'] = request.certificateType;
  }
  if (!$isNull(request.imageUrl)) {
    body['ImageUrl'] = request.imageUrl;
  }
  if (!$isNull(request.resultType)) {
    body['ResultType'] = request.resultType;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TranslateCertificate',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary TranslateCertificate
 *
 * @param request TranslateCertificateRequest
 * @return TranslateCertificateResponse
 */
async function translateCertificate(request: TranslateCertificateRequest): TranslateCertificateResponse {
  var runtime = new $RuntimeOptions{};
  return translateCertificateWithOptions(request, runtime);
}

async function translateCertificateAdvance(request: TranslateCertificateAdvanceRequest, runtime: $RuntimeOptions): TranslateCertificateResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if($isNull(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if($isNull(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApiUtil.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'alimt',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var translateCertificateReq = new TranslateCertificateRequest{};
  OpenApiUtil.convert(request, translateCertificateReq);

  if(!$isNull(request.imageUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.imageUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    translateCertificateReq.imageUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var translateCertificateResp = translateCertificateWithOptions(translateCertificateReq, runtime);
  return translateCertificateResp;
}

model TranslateECommerceRequest {
  context?: string(name='Context', example='context信息'),
  formatType?: string(name='FormatType', description='This parameter is required.', example='text'),
  scene?: string(name='Scene', description='This parameter is required.', example='social'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='en'),
  sourceText?: string(name='SourceText', description='This parameter is required.', example='Hello'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='zh'),
}

model TranslateECommerceResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    detectedLanguage?: string(name='DetectedLanguage'),
    translated?: string(name='Translated'),
    wordCount?: string(name='WordCount', example='10'),
  }(name='Data'),
  message?: string(name='Message', example='An error occurred while translating.'),
  requestId?: string(name='RequestId', example='CC93BB5C-EAB5-579B-AA44-F61528F48FF8'),
}

model TranslateECommerceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateECommerceResponseBody(name='body'),
}

/**
 * @deprecated OpenAPI TranslateECommerce is deprecated, please use alimt::2018-10-12::Translate instead.
 *
 * @summary TranslateECommerce
 *
 * @param request TranslateECommerceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateECommerceResponse
 */
// Deprecated
async function translateECommerceWithOptions(request: TranslateECommerceRequest, runtime: $RuntimeOptions): TranslateECommerceResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.context)) {
    query['Context'] = request.context;
  }
  var body : map[string]any = {};
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TranslateECommerce',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @deprecated OpenAPI TranslateECommerce is deprecated, please use alimt::2018-10-12::Translate instead.
 *
 * @summary TranslateECommerce
 *
 * @param request TranslateECommerceRequest
 * @return TranslateECommerceResponse
 */
// Deprecated
async function translateECommerce(request: TranslateECommerceRequest): TranslateECommerceResponse {
  var runtime = new $RuntimeOptions{};
  return translateECommerceWithOptions(request, runtime);
}

model TranslateGeneralRequest {
  context?: string(name='Context', example='{\\\\"appName\\\\":\\\\"alynx\\\\"}'),
  formatType?: string(name='FormatType', description='This parameter is required.', example='text'),
  scene?: string(name='Scene', example='general'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  sourceText?: string(name='SourceText', description='This parameter is required.'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model TranslateGeneralResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    detectedLanguage?: string(name='DetectedLanguage'),
    translated?: string(name='Translated', example='Hello'),
    wordCount?: string(name='WordCount', example='10'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='86D18195-D89C-4C8C-9DC4-5FCE789CE6D5'),
}

model TranslateGeneralResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateGeneralResponseBody(name='body'),
}

/**
 * @summary 文本通用翻译
 *
 * @param request TranslateGeneralRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateGeneralResponse
 */
async function translateGeneralWithOptions(request: TranslateGeneralRequest, runtime: $RuntimeOptions): TranslateGeneralResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.context)) {
    query['Context'] = request.context;
  }
  var body : map[string]any = {};
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TranslateGeneral',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 文本通用翻译
 *
 * @param request TranslateGeneralRequest
 * @return TranslateGeneralResponse
 */
async function translateGeneral(request: TranslateGeneralRequest): TranslateGeneralResponse {
  var runtime = new $RuntimeOptions{};
  return translateGeneralWithOptions(request, runtime);
}

model TranslateGeneralVpcRequest {
  context?: string(name='Context'),
  formatType?: string(name='FormatType', description='This parameter is required.', example='text'),
  scene?: string(name='Scene', description='This parameter is required.', example='general'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  sourceText?: string(name='SourceText', description='This parameter is required.'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model TranslateGeneralVpcResponseBody = {
  code?: int32(name='Code', description='This parameter is required.', example='200'),
  data?: {
    detectedLanguage?: string(name='DetectedLanguage', example='zh'),
    translated?: string(name='Translated', example='Hello'),
    wordCount?: string(name='WordCount', example='10'),
  }(name='Data'),
  message?: string(name='Message', example='translate from source to target not support'),
  requestId?: string(name='RequestId', description='Id of the request', example='DC2DCCC9-C3DF-4F59-8D8E-78185729F16D'),
}

model TranslateGeneralVpcResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateGeneralVpcResponseBody(name='body'),
}

/**
 * @summary TranslateGeneralVpc
 *
 * @param request TranslateGeneralVpcRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateGeneralVpcResponse
 */
async function translateGeneralVpcWithOptions(request: TranslateGeneralVpcRequest, runtime: $RuntimeOptions): TranslateGeneralVpcResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.context)) {
    query['Context'] = request.context;
  }
  var body : map[string]any = {};
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TranslateGeneralVpc',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary TranslateGeneralVpc
 *
 * @param request TranslateGeneralVpcRequest
 * @return TranslateGeneralVpcResponse
 */
async function translateGeneralVpc(request: TranslateGeneralVpcRequest): TranslateGeneralVpcResponse {
  var runtime = new $RuntimeOptions{};
  return translateGeneralVpcWithOptions(request, runtime);
}

model TranslateImageRequest {
  ext?: string(name='Ext', example='{"needEditorData": "false", "ignoreEntityRecognize": "true"}'),
  field?: string(name='Field', example='general'),
  imageBase64?: string(name='ImageBase64', example='/9j/4...H/9k='),
  imageUrl?: string(name='ImageUrl', example='https://example.com/example.jpg'),
  sourceLanguage?: string(name='SourceLanguage', example='zh'),
  targetLanguage?: string(name='TargetLanguage', example='en'),
}

model TranslateImageResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    finalImageUrl?: string(name='FinalImageUrl', example='https://example.com/example.jpg'),
    inPaintingUrl?: string(name='InPaintingUrl', example='https://example.com/example.jpg'),
    templateJson?: string(name='TemplateJson', example='Editor Template Json String'),
  }(name='Data'),
  message?: string(name='Message', example='Error Message'),
  requestId?: string(name='RequestId', example='D774D33D-F1CB-5A2C-A787-E0A2179239CE'),
}

model TranslateImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateImageResponseBody(name='body'),
}

/**
 * @summary 公有云图片翻译产品API
 *
 * @param request TranslateImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateImageResponse
 */
async function translateImageWithOptions(request: TranslateImageRequest, runtime: $RuntimeOptions): TranslateImageResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.ext)) {
    body['Ext'] = request.ext;
  }
  if (!$isNull(request.field)) {
    body['Field'] = request.field;
  }
  if (!$isNull(request.imageBase64)) {
    body['ImageBase64'] = request.imageBase64;
  }
  if (!$isNull(request.imageUrl)) {
    body['ImageUrl'] = request.imageUrl;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TranslateImage',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 公有云图片翻译产品API
 *
 * @param request TranslateImageRequest
 * @return TranslateImageResponse
 */
async function translateImage(request: TranslateImageRequest): TranslateImageResponse {
  var runtime = new $RuntimeOptions{};
  return translateImageWithOptions(request, runtime);
}

model TranslateImageBatchRequest {
  customTaskId?: string(name='CustomTaskId', example='my_awesome_task_1'),
  ext?: string(name='Ext', example='{"needEditorData": "false", "ignoreEntityRecognize": "true"}'),
  field?: string(name='Field', example='general'),
  imageUrls?: string(name='ImageUrls', description='This parameter is required.', example='https://example.com/1.jpg,https://example.com/2.jpg,https://example.com/3.jpg'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model TranslateImageBatchResponseBody = {
  code?: int32(name='Code', example='200'),
  data?: {
    taskId?: string(name='TaskId', example='EEA28E6D-4828-5031-BD8C-8FF1B3216842'),
  }(name='Data'),
  message?: string(name='Message', example='OK'),
  requestId?: string(name='RequestId', example='D774D33D-F1CB-5A2C-A787-E0A2179239CE'),
}

model TranslateImageBatchResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateImageBatchResponseBody(name='body'),
}

/**
 * @summary 批量图片翻译接口
 *
 * @param request TranslateImageBatchRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateImageBatchResponse
 */
async function translateImageBatchWithOptions(request: TranslateImageBatchRequest, runtime: $RuntimeOptions): TranslateImageBatchResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.customTaskId)) {
    body['CustomTaskId'] = request.customTaskId;
  }
  if (!$isNull(request.ext)) {
    body['Ext'] = request.ext;
  }
  if (!$isNull(request.field)) {
    body['Field'] = request.field;
  }
  if (!$isNull(request.imageUrls)) {
    body['ImageUrls'] = request.imageUrls;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TranslateImageBatch',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 批量图片翻译接口
 *
 * @param request TranslateImageBatchRequest
 * @return TranslateImageBatchResponse
 */
async function translateImageBatch(request: TranslateImageBatchRequest): TranslateImageBatchResponse {
  var runtime = new $RuntimeOptions{};
  return translateImageBatchWithOptions(request, runtime);
}

model TranslateSearchRequest {
  formatType?: string(name='FormatType', description='This parameter is required.', example='text', nullable=false),
  scene?: string(name='Scene', description='This parameter is required.', example='query'),
  sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='zh', nullable=false),
  sourceText?: string(name='SourceText', description='This parameter is required.', example='今天天气不错'),
  targetLanguage?: string(name='TargetLanguage', description='This parameter is required.', example='en'),
}

model TranslateSearchResponseBody = {
  code?: string(name='Code'),
  data?: {
    translated?: string(name='Translated'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model TranslateSearchResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateSearchResponseBody(name='body'),
}

/**
 * @summary 搜索翻译
 *
 * @param request TranslateSearchRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateSearchResponse
 */
async function translateSearchWithOptions(request: TranslateSearchRequest, runtime: $RuntimeOptions): TranslateSearchResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.formatType)) {
    body['FormatType'] = request.formatType;
  }
  if (!$isNull(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!$isNull(request.sourceLanguage)) {
    body['SourceLanguage'] = request.sourceLanguage;
  }
  if (!$isNull(request.sourceText)) {
    body['SourceText'] = request.sourceText;
  }
  if (!$isNull(request.targetLanguage)) {
    body['TargetLanguage'] = request.targetLanguage;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TranslateSearch',
    version = '2018-10-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 搜索翻译
 *
 * @param request TranslateSearchRequest
 * @return TranslateSearchResponse
 */
async function translateSearch(request: TranslateSearchRequest): TranslateSearchResponse {
  var runtime = new $RuntimeOptions{};
  return translateSearchWithOptions(request, runtime);
}

